package com.sy.dao.impl;

import com.sy.dao.TypeDao;
import com.sy.entity.Type;

import java.util.ArrayList;
import java.util.List;

import static com.sy.constant.BusinessConstant.ALL_BRAND_ID;

public class TypeDaoImpl extends AbstractDaoImpl implements TypeDao {
    @Override
    public List<Type> getTypesByBrandId(Integer brandId) {
        StringBuilder sql = new StringBuilder();
        List<Object> params = new ArrayList<>();
        sql.append("select * from t_type");
        if (!brandId.equals(ALL_BRAND_ID)) {
            sql.append(" where brandid=?");
            params.add(brandId);
        }
        return queryForList(sql.toString(), Type.class, params.toArray());
    }
}
